package com.example.societiesSystem.service.impl;

import com.example.societiesSystem.dto.ActivityLogsAddDTO;
import com.example.societiesSystem.entity.ActivityPersonnelRecording;
import com.example.societiesSystem.entity.User;
import com.example.societiesSystem.mapper.ActivityPersonnelRecordingMapper;
import com.example.societiesSystem.service.IActivityPersonnelRecordingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.societiesSystem.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 社团活动人员记录表 服务实现类
 * </p>
 *
 * @author 周欢
 * @since 2025-05-27
 */
@Service
public class ActivityPersonnelRecordingServiceImpl extends ServiceImpl<ActivityPersonnelRecordingMapper, ActivityPersonnelRecording> implements IActivityPersonnelRecordingService {

    @Resource
    private IUserService userService;

    @Override
    public boolean add(ActivityLogsAddDTO activityLogsAddDTO) {
        ActivityPersonnelRecording activityPersonnelRecording = new ActivityPersonnelRecording();
        User user = userService.getById(activityLogsAddDTO.getToken());
        activityPersonnelRecording.setUserId(String.valueOf(user.getId()));
        activityPersonnelRecording.setUserName(user.getUserName());
        activityPersonnelRecording.setUserPhone("13203050639");
        activityPersonnelRecording.setActiveId(activityLogsAddDTO.getActiveId());
        activityPersonnelRecording.setCreateTime(LocalDateTime.now());
        return this.save(activityPersonnelRecording);
    }
}
